// This file tests the functions defined in LiveFolders.js, which will typically be helpers and global functions
// that are useful across all pages.  As such, it is OK to define multiple test classes in here.

registerNamespace("Gimme.UnitTests");
Gimme.UnitTests.SelectorTests = function()
{
	// .setUp is executed before each test
	this.setUp = function()
	{
		document.body.innerHTML =
		'<div id = "zoo" class = "place man-made">' +
			'<span id = "panda1" class = "panda">Panda1</span>' +
			'<span id = "tiger1" class = "tiger">Tiger1</span>' +
			'<span id = "panda2" class = "panda">Panda2</span>' +
		'</div>' +
		'<div id = "forest" class = "place natural">' +
			'<p id = "tree1" class = "tree pine">Pine tree 1</p>' +
			'<p id = "tree2" class = "tree oak">Oak tree 1</p>' +
			'<span id = "chipmunk1" class = "mammal chipmunk">Chipmunk 1</span>' +
			'<span id = "gazelle1" class = "mammal gazelle">Gazelle 1</span>' +
			'<p id = "ivyPlant1" class = "ivy poison">Poison Ivy Plant 1</p>' +
		'</div>';
	};
	
	this.test_selectIdZoo = function()
	{
		var gObj = g('#zoo');
		AtlasUnit.Assert.elementsEqual(this.get('zoo'), gObj.entities, 'Arrays are not equal');
	};
	
	this.test_selectIdForest = function()
	{
		var gObj = g('#forest');
		AtlasUnit.Assert.elementsEqual(this.get('forest'), gObj.entities, 'Arrays are not equal');
	};
	
	this.test_classMammal_in_IdForest = function()
	{
		var gObj = g('#forest .mammal');
		AtlasUnit.Assert.elementsEqual(this.get('chipmunk1', 'gazelle1'), gObj.entities, 'Arrays are not equal');
	};
	
	this.test_firstChild_of_IdZoo = function()
	{
		var gObj = g('#zoo *:first-child');
		AtlasUnit.Assert.elementsEqual(this.get('panda1'), gObj.entities, 'Arrays are not equal');
	};	
	
	// helper functions
	this.get = function()
	{
		var arr = [];
		var ids = arguments;
		var i, len = ids.length;
		for (i = 0; i < len; i++)
		{
			arr.push(document.getElementById(ids[i]));
		}
		
		return arr;
	}

}
Gimme.UnitTests.SelectorTests.registerClass("Gimme.UnitTests.SelectorTests");
Gimme.UnitTests.SelectorTests["AtlasUnit.IsTestFixture"] = true;
